package com.example.administrator.college02.helper;

import android.content.Context;

import java.io.IOException;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by Administrator on 2016/7/15.
 */
public class OkHttpHelper {
    public  static String  getRequest(Context context, OkHttpClient client, String url){

        String str = "";
        Request request=new Request.Builder()
                .get()
                .tag(context)
                .url(url)
                .build();

        Response response = null;
        try {
            response = client.newCall(request).execute();
            if (response.isSuccessful()) {
                str = response.body().string();

            } else {
                throw new IOException("Unexpected code " + response);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        return str;
    }

}
